package com.xiaoke.liantongdemo.widget;

import com.xiaoke.liantongdemo.R;
import com.xiaoke.liantongdemo.R.drawable;
import com.xiaoke.liantongdemo.bean.Category;

import android.content.Context;
import android.util.Log;
import android.view.Gravity;
import android.widget.AbsListView;
import android.widget.Gallery;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class CategoryLayout extends RelativeLayout {
	
	private Context context;
	private Category category;

	public CategoryLayout(Context context, Category category) {
		super(context);
		this.context = context;
		this.category = category;
		init();
	}
	
	private void init(){
		setLayoutParams(new AbsListView.LayoutParams(LayoutParams.FILL_PARENT,270));
		setBackgroundResource(R.drawable.booklayer);
//		setPadding(20, 0, 20, 0);
		TextView name = new TextView(context);
		name.setBackgroundResource(R.drawable.booklayertitle);
		name.setText(category.getName());
		name.setGravity(Gravity.CENTER);
		name.setTextSize(20);
		name.setTextColor(0xffffffff);
		LayoutParams nameParams = new LayoutParams(187, 36);
		nameParams.setMargins(50, 30, 0, 0);
		addView(name, nameParams);
//		MyGallery books = new MyGallery(context);
//		books.setAdapter(new BookLayerAdapter(context, bookLayer.getBooks()));
//		LayoutParams booksParams = new LayoutParams(LayoutParams.FILL_PARENT, 80);
//		booksParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
//		addView(books, booksParams);
		BusinessesLayout booksLayout = new BusinessesLayout(context, category.getBusinesses());
		LayoutParams categoryParams = new LayoutParams(700, 160);
		categoryParams.setMargins(50, 0, 50, 0);
		categoryParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		addView(booksLayout, categoryParams);
	}

}
